package com.yimi.yinhepda.adapter.unload_offline;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.yimi.yinhepda.R;
import com.yimi.yinhepda.entity.bean.AddEntity;
import java.util.List;

/**
 * Created by 000432 on 2017/9/12
 * @author 000432
 */

public class UnloadOffLineAddAdapter extends BaseAdapter {
  LayoutInflater inflater;
  List<AddEntity> dataList;

  public UnloadOffLineAddAdapter(Context context, List<AddEntity> dataList) {
    this.dataList = dataList;
    this.inflater = (LayoutInflater) context
        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  }

  @Override
  public int getCount() {
    return null != dataList ? dataList.size() : 0;
  }


  @Override
  public View getView(int position, View convertView, ViewGroup arg2) {
    ViewHolder holder = null;
    if (convertView == null) {
      holder = new ViewHolder();
      convertView = inflater.inflate(R.layout.unload_offline_add_item, null);
      holder.serialNum = (TextView) convertView.findViewById(R.id.tv_serialNum);
      holder.childWayBill = (TextView) convertView.findViewById(R.id.tv_childWayBill);
      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    holder.serialNum.setText(position+1+"");
    holder.childWayBill.setText(dataList.get(position).getChildwayBillNum());

    return convertView;
  }

  static class ViewHolder {
    TextView serialNum;
    TextView childWayBill;
  }

  @Override
  public Object getItem(int position) {
    return dataList.get(position);
  }

  @Override
  public long getItemId(int position) {
    return position;
  }
}
